﻿package com.Galaxisfarm {
	import com.adamatomic.flixel.*;
	
	public class WinnerState extends FlxState {
		[Embed(source = "../../data/background.png")] private var ImgBack:Class;
		
		private static var lyrStage:FlxLayer;
		
		public function WinnerState():void {
			lyrStage = new FlxLayer;
			
			var background:FlxSprite = new FlxSprite(ImgBack);
			lyrStage.add(background);
			this.add(lyrStage);
			
			this.add(new FlxText(0, (FlxG.height / 2), FlxG.width, 80, "Venceu", 0xffffffff, null, 26, "center")) as FlxText;
			this.add(new FlxText(0, (FlxG.height / 2) + 30, FlxG.width, 8, "Parabéns,\nvocê tem uma pecuária sustentável e produtiva.", 0xffffffff, null, 16, "center"));
			this.add(new FlxText(0, FlxG.height - 24, FlxG.width, 8, "Pressione X para recomeçar", 0xffffffff, null, 8, "center"));
		}
		
		override public function update():void {
			if (FlxG.kA) {
				FlxG.flash(0xffffffff, 0.75);
				FlxG.fade(0xff000000, 1, onFade);
			}
			
			super.update();
		}
		
		private function onFade():void {
			FlxG.switchState(MenuState);
		}
	}
}